projects
/
emacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
df52aeb
)
* floatfns.c (Fexpt): Avoid unnecessary multiplications.
author
Paul Eggert
<eggert@cs.ucla.edu>
Thu, 6 Oct 2011 07:51:21 +0000
(
00:51
-0700)
committer
Paul Eggert
<eggert@cs.ucla.edu>
Thu, 6 Oct 2011 07:51:21 +0000
(
00:51
-0700)
src/floatfns.c
patch
|
blob
|
history
diff --git
a/src/floatfns.c
b/src/floatfns.c
index 6158b9bd26d2f3306ba35884a0d7aa6764930fac..f8b775011ae00cdff1a09502895fb19bd69cb3f9 100644
(file)
--- a/
src/floatfns.c
+++ b/
src/floatfns.c
@@
-490,26
+490,13
@@
DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
x = XINT (arg1);
y = XINT (arg2);
- acc =
1
;
+ acc =
(y & 1 ? x : 1)
;
-
if (y <
0)
+
while ((y >>= 1) !=
0)
{
- if (x == 1)
- acc = 1;
- else if (x == -1)
- acc = (y & 1) ? -1 : 1;
- else
- acc = 0;
- }
- else
- {
- while (y > 0)
- {
- if (y & 1)
- acc *= x;
- x *= x;
- y >>= 1;
- }
+ x *= x;
+ if (y & 1)
+ acc *= x;
}
XSETINT (val, acc);
return val;